<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<html>
	<head>
		<title>进销存</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link rel="shortcut icon" href="images/system/china_mobile.ico"
			type="image/x-icon" />
		<link rel="stylesheet" type="text/css"
			href="scripts/ext/resources/css/ext-all.css">
		<link rel="stylesheet" type="text/css"
			href="scripts/ext/resources/css/icon.css">
		<link rel="stylesheet" type="text/css"
			href="scripts/utils/HiTRUST-CMS.css">
		<script type="text/javascript" src="scripts/ext/ext-base.js"></script>
		<script type="text/javascript" src="scripts/ext/ext-all.js"></script>
		<script type="text/javascript" src="scripts/ext/TabCloseMenu.js"></script>
		<script type="text/javascript" src="scripts/ext/ext-lang-zh_CN.js"></script>
		<style type="text/css">
.font_b {
	color: blue;
	font-size: 16px;
	font-weight: bold;
}
</style>
	</head>

	<body scroll="no" id="docs">
	<!-- 获取登陆人ID -->
		<div id="loading-mask" style=""></div>
		<div id="loading">
			<div class="loading-indicator">
				<img src="images/loading.gif" width="32" height="32"
					style="margin-right: 8px;" align="absmiddle" />
				请稍等...
				<br/>如果长时间无法载入页面，请刷新页面，或者点击<a href="javascript:window.location.reload();">刷新</a>
			</div>
		</div>
		<script type="text/javascript">
		//************格式化日期格式*************
		Date.prototype.format = function(format)   
		{   
		   	var o = {   
		    	"M+" : this.getMonth()+1, //month   
		     	"d+" : this.getDate(),    //day   
		     	"h+" : this.getHours(),   //hour   
		     	"m+" : this.getMinutes(), //minute   
		     	"s+" : this.getSeconds(), //second   
		     	"q+" : Math.floor((this.getMonth()+3)/3), //quarter   
		     	"S" : this.getMilliseconds() //millisecond   
		   	}   
		   	if(/(y+)/.test(format)){ 
		   		format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
		   	}  
			for(var k in o){
				if(new RegExp("("+ k +")").test(format)){
		    		format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr((""+ o[k]).length));   
		     	}
		    }
		   return format;   
		} 
		function ReLoadPage(){
			document.execCommand("Refresh");
		}
		var timeShowWin;
		var messageWin;
		var currMsg;
  		//设置默认图标
  		Ext.BLANK_IMAGE_URL = 'scripts/ext/resources/images/s.gif';
  		/*------------------------------------------------------------------------------------*/
  		/*树形结构*/
  		var windIndex=0;
  		var centerTabPanel;
  		/*启动程序，创建窗体和布局*/
  		Ext.onReady(function(){
  			Ext.QuickTips.init();
			Ext.form.Field.prototype.msgTarget='side';
  			/*-------------创建中间面板-------------*/
  			var menuArray = new Array();
  			//----------------------菜单数据库初始化strat-----------------------------------------

 		  	Ext.Ajax.request({
							method : 'POST',
							url : '/fz_jxc/opControl/InitMenu.do',
							success : function(response, options) {
								jsonArray = Ext.util.JSON.decode(response.responseText);
								views();
							},
							failure : function() {
							}
						});		
			//----------------------菜单数据库初始化end-----------------------------------------
var viewport;
function views(){
			var welcome;
  			for(var i=0;i<jsonArray.length;i++){
  				
  				var menu=-1;
  				var menuChild=-1;
  				var menuChildTemp=-1;
  				for(var ii=0;ii<jsonArray[i].length;ii++){
  					
  					if(jsonArray[i][ii].url!=''){
  						if(jsonArray[i][ii].name=="进销存"){
  							welcome=jsonArray[i][ii].url;
  							continue;
  						}
		 				menuChildTemp = new Ext.Panel({
			  				id:'GDCM'+(++windIndex),
							title:"<a href=javascript:addNewTab('"+jsonArray[i][ii].url+"','"+jsonArray[i][ii].name+"','"+jsonArray[i][ii].iconCls+"',"+(100)+")>"+jsonArray[i][ii].name+"</a>",
							iconCls:jsonArray[i][ii].iconCls,
							border:false
	  					});
	  					if(menuChild==-1){
	  						menuChild=menuChildTemp;
	  					}else{
	  						menuChildTemp.add(menuChild);
	  						menuChild=menuChildTemp;
	  					}
  					}else{
  						menu = new Ext.Panel({
			  				id:'GDCM'+(++windIndex),
						  	title:"<label class='font_b'>"+jsonArray[i][ii].name+"</label>",
						  	border:false,
						  	iconCls:jsonArray[i][ii].iconCls
			  			});
  					}
  				}
  				menu.add(menuChild);
  				menuArray[i]=menu;
  			}	
  			if(welcome==null){
  				welcome="/fz_jxc/error404.jsp";
  			}
  			centerTabPanel=new Ext.TabPanel({
	  			region:'center',
	  			autoScroll:true,
	  			animScroll:true,
	  			resizTabs:true,
	  			enableTabScroll:true,
	  			activeTab:0,
	  			deferredRender:false,
	  			defaults: {
	  				autoScroll:true
	  			},
	  			tabMargin:0,
	  			plugins: new Ext.ux.TabCloseMenu(),
	  			items:[{
	  				//closable:true,//是否使用关闭功能
	  				id:'mainFrame',
	  				title: '进销存',
	  				iconCls:'icon-root-s',
	  				html:'<div style="width:100%;height:100%;background:#90EE90"><iframe scrolling=auto frameborder=0 width=100% height=100% src="'+welcome+'"></iframe></div>',
	  				autoScroll:true
	  			}]
  			});
  			/*-----------菜单----------*/
  			/*-----------创建TAB项，并且整合中间面板----------*/
  			viewport=new Ext.Viewport({
  				layout:'border',
  				items:[{
  					//头部分	
  					region:'north',
                    margins:'0 0 0 0',
  					html:'<img src="images/system/top.jpg" width="100%" height="20">',
  				    width: 150
  				},{
  					region:'west',
                    id:'west',
                    title:'进销存',
                    tools:[
                    	{id:"refresh",qtip:'刷新本页面',text:'刷新',handler:function(){ReLoadPage();}},
                    	{id:"close",qtip:'安全退出',handler:function(){window.location.href="login/action_logout.do";}}
                    ],
                    width: 160,
                    minSize: 150,//最小宽度
                   	maxSize: 300,//最大宽度
                   	split:true,
                    collapsible: true,
                    //titleCollapse: true,
                    fitToFrame: true,
                    closable:true,//是否使用关闭功能
                    margins:'0 0 0 2',
                    layout:'accordion',//下拉功能属性
                    layoutConfig:{
                        animate:true
                    },
                    //items:[menuArray[0],menuArray[1],menuArray[2]]
                    items:menuArray
  				}, centerTabPanel]
                })
 }
  		});

  		/*------------------------------------------------------------------------------------*/
  		//添加一个TAB页，采用IFRAME嵌套
  		function addNewTab(newUrl,urlName,icon,sqId){
  			var idd="GDCM"+sqId;
  			//获取面板
  			var tabEle = centerTabPanel.getItem(idd);
  			if(tabEle){
  				centerTabPanel.remove(tabEle,true);
  			}
  			//判断面板是否打开
  			//if(!tabEle){
		  		tabEle=centerTabPanel.add({
		  			closable:true,
		  			id:idd,
		  			title:urlName,
		  			html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src='+newUrl+' id="tabFrame"></iframe>',
		  			autoShow:true,
		  			iconCls:icon
		  		});
  			//}
  			centerTabPanel.setActiveTab(tabEle);
  		}
  		function removeTabByIdd(sqId){
	  		var idd="GDCM"+sqId;
	  		try{
		  		var tabEle = centerTabPanel.getItem(idd);
		  		if(tabEle){
		  			centerTabPanel.remove(tabEle,true);
		  		}
	  		}catch(e){}
  		}
  	</script>

		<script>
	var timerID = null;
	var timerRunning = false;
	function stopclock (){
		if(timerRunning)
		clearTimeout(timerID);
		timerRunning = false;
	}
	function startclock () {
		stopclock();
		showtime();
	}
	function showtime() {
		if(Ext.get("clockShow")!=null){
			var now = new Date();
			var hours = now.getHours();
			var minutes = now.getMinutes();
			var seconds = now.getSeconds()
			var timeValue = now.getYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日" +((hours >= 12) ? " 下午 " : " 上午 " )
			timeValue += ((hours >12) ? hours -12 :hours)
			timeValue += ((minutes < 10) ? ":0" : ":") + minutes
			timeValue += ((seconds < 10) ? ":0" : ":") + seconds
			Ext.get("clockShow").dom.innerHTML = timeValue;
		}
		timerID = setTimeout("showtime()",1000);
		timerRunning = true;
	}
    </script>
</body>
</html>